<%
  if !check_window(@min_est, @max_est, @min_event, @max_event, @leadlag_size)
%>
    Wrong Window Setting!
<%
  elsif !check_tradedate(@id, @stock_type, @event_date)
    min_date,max_date = get_minmax_tradedate(@id, @stock_type)
%>
    Wrong Event Date!<br/>
    (Min: <%=min_date%>  , Max: <%=max_date%>)
<%
  else
    if @stock_type=='S'
      stock = Stock.find(:first, :conditions=>["id=?",@id])
      if stock
        pass,label = check_est_event_pass(stock, @stock_type, @event_date, @min_est, @max_est, @min_event, @max_event)
        xml = get_checkchart_xml(pass,label)
%>
        <span id='chartdiv_<%=@no%>' align='center'></span>
        <script type='text/javascript'>
          var myChart = new FusionCharts("/Charts/HLinearGauge.swf", "myChartId<%=@no%>", "280", "55", "0", "0");
          myChart.setDataXML("<%=xml%>");
          myChart.render("chartdiv_<%=@no%>");
        </script>
<%
      end
    else
      stock = UserStock.find(:first, :conditions=>["id=?",@id])
      if stock
        pass,label = check_est_event_pass(stock, @stock_type, @event_date, @min_est, @max_est, @min_event, @max_event)
        xml = get_checkchart_xml(pass,label)
%>
        <span id='chartdiv_<%=@no%>' align='center'></span>
        <script type='text/javascript'>
          var myChart = new FusionCharts("/Charts/HLinearGauge.swf", "myChartId<%=@no%>", "280", "55", "0", "0");
          myChart.setDataXML("<%=xml%>");
          myChart.render("chartdiv_<%=@no%>");
        </script>
<%
      end
    end
  end
%>